package com.yunhe.java.others; /**
 * Created by Administrator on 2017/7/26 0026.
 */
import java.util.Scanner;
public class cccc {


    /**
     * Created by Administrator on 2017/7/26 0026.
     */

        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.print("请输入要答应的杨辉三角的行数：");
            int row = scanner.nextInt();  //行数
            int[][] arr = new int[row][row];
        /*给每行 放 1*/
            for(int i = 0;i<arr.length ; i++){
                arr[i][0] = 1;
                arr[i][i] =1;
            }

        /*算中间的值*/
            for(int i = 2; i < arr.length; i++) {
                for(int j= 1; j < i;j++){
                    arr[i][j] = arr[i-1][j] + arr[i-1][j-1];
                }
            }

        /*遍历展示*/
            for(int i = 0;i < arr.length; i++){
                for(int j = 0; j <= i; j++) {
                    System.out.print(arr[i][j] + " ");
                }
                System.out.println();
            }

        }


}
